#framing descriptive stats
#alan yan
#2-22-22

####setup####
#clear environment
rm(list = ls())

#load packages
pacman::p_load(tidyverse,
               DeclareDesign,
               stargazer,
               hrbrthemes)

#load data
dt <- read_rds("02-framing-experiment/data/clean-data-stacked-pol")

#### make tables S158 and S159 ####
#### *DUMMYING CATEGORICAL VARIBLES ####
#Sex
for(i in unique(dt$woman)) {
  dt[i] <- ifelse(dt$woman == i, 1, 0)
}

#Income
for(i in unique(dt$hhi_c)) {
  dt[i] <- ifelse(dt$hhi_c == i, 1, 0)
}

#Education
for(i in unique(dt$education_c)) {
  dt[i] <- ifelse(dt$education_c == i, 1, 0)
}

#ethnicity
for(i in unique(dt$ethnicity)) {
  dt[i] <- ifelse(dt$ethnicity == i, 1, 0)
}

#Hispanic
for(i in unique(dt$hispanic)) {
  dt[i] <- ifelse(dt$hispanic == i, 1, 0)
}

#Employment
for(i in unique(dt$r_industry)) {
  dt[i] <- ifelse(dt$r_industry == i, 1, 0)
}

#occupation
for(i in unique(dt$r_occupation)) {
  dt[i] <- ifelse(dt$r_occupation == i, 1, 0)
}

#Union
for(i in unique(dt$r_union)) {
  dt[i] <- ifelse(dt$r_union == i, 1, 0)
}

#political party
for(i in unique(dt$political_party_c)) {
  dt[i] <- ifelse(dt$political_party_c == i, 1, 0)
}

covariates <- names(dt)[71:152]

dt[match(unique(dt$rid), dt$rid),] %>%
  select(covariates) %>%
  as.data.frame() %>%
  stargazer(., summary = TRUE,
            summary.stat = c("mean", "sd", "n")
            )
